{% extends 'djangobb_forum/base.html' %}
{% load forum_extras %}
{% load pagination_tags %}
{% load i18n %}

{% block title %} / {{ topic.forum.name }} / {{ topic.name }}{% endblock %}
{% block content %}
{% autopaginate posts forum_settings.TOPIC_PAGE_SIZE %}
<div class="linkst">
	<div class="inbox">
		<div class="pagelink conl">{% paginate %}</div>
		{% if not topic.closed and user.is_authenticated %}
			<p class="postlink conr"><a href="{% url djangobb:add_post topic.id %}">{% trans "Reply" %}</a></p>
		{% endif %}
		<ul>
			<li>
			<a href="{% url djangobb:index %}">{% trans "Root" %} </a></li><li>&raquo; {% link topic.forum %} </li><li>&raquo; {{ topic.name }}
			<a href="{% url djangobb:forum_topic_feed topic.id %}"><img src="{{ STATIC_URL }}djangobb_forum/img/feed-icon-small.png" alt="[RSS Feed]" title="[RSS Feed]" class="breadcrumb_rss" /></a>
			</li>
		</ul>
		<div class="clearer"></div>
	</div>
</div>
{% for post in posts %}
	<div id="p{{ post.id }}" class="blockpost roweven firstpost">
		<a name="post-{{ post.id }}"></a>
		<h2><span><span class="conr">#{{ forloop.counter }}&nbsp;</span><a href="{{ post.get_absolute_url }}">{% forum_time post.created %}</a></span></h2>
		<div class="box">
			<div class="inbox">
				<div class="postleft">
					<dl>
						<dt><strong><a href="javascript:pasteN('{{ post.user.username }}');">{{ post.user.username }}</a></strong></dt>
						<dd class="usertitle">
							{% if post.user.forum_profile.status %}
								<strong>{{ post.user.forum_profile.status }}</strong>
							{% else %}
								<strong>{{ post.user.forum_profile.group }}</strong>
							{% endif %}
						</dd>
						{% if forum_settings.AUTHORITY_SUPPORT %}
							<dd class="usertitle">
								{{ post.user|forum_authority }}
							</dd>
						{% endif %}
						<dd class="postavatar">
							{% if post.user.forum_profile.avatar and post.user.forum_profile.show_avatar %}
								<img src="{{ post.user.forum_profile.avatar.url }}" />
							{% else %}
								{% if forum_settings.GRAVATAR_SUPPORT %}
									<img src="{% gravatar post.user.email %}" />
								{% endif %}
							{% endif %}
						</dd>
						{% if post.user.forum_profile.location %}
							<dd>{% trans "From:" %} {{ post.user.forum_profile.location }}</dd>
						{% endif %}
						<dd>{% trans "Registered:" %} {{ post.user.date_joined|date:"Y-m-d" }}</dd>
						<dd>{% trans "Posts:" %} {{ post.user.forum_profile.post_count }}</dd>
						{% if moderator %}
							<dd>{% trans "IP:" %} {{ post.user_ip }}</dd>
						{% endif %}
						{% if forum_settings.REPUTATION_SUPPORT %}
								<dd><a href="{% url djangobb:reputation post.user.username %}">{% trans "Reputation" %}</a>:
								{% if request.user != post.user %} {# TODO: and user.is_authenticated #}
									<a href="{% url djangobb:reputation post.user.username %}?action=plus&amp;post_id={{ post.id }}"><img src="{{ STATIC_URL }}djangobb_forum/img/reputation/warn_add.gif" alt="+" /></a>&nbsp;&nbsp;<strong>{{ post.user.forum_profile.reply_total|default_if_none:"0" }}&nbsp;&nbsp;</strong><a href="{% url djangobb:reputation post.user.username %}?action=minus&amp;post_id={{ post.id }}"><img src="{{ STATIC_URL }}djangobb_forum/img/reputation/warn_minus.gif" alt="-" /></a>
								{% else %}
									<strong>{{ post.user.forum_profile.reply_total|default_if_none:"0" }}</strong>
								{% endif %}
								</dd>
						{% endif %}
						<dd class="usercontacts"><a href="{% url djangobb:forum_profile post.user.username %}">{% trans "Profile" %}</a>&nbsp;&nbsp;
						{% if post.user.forum_profile.privacy_permission == 0 %}
							<a href="mailto:{{ post.user.email }}">{% trans "E-mail" %}</a>&nbsp;&nbsp;
						{% else %}
							{% if post.user.forum_profile.privacy_permission == 1 %}
								<a href="{% url djangobb:misc %}?mail_to={{ post.user.username }}">{% trans "Send e-mail" %}</a>&nbsp;&nbsp;
							{% endif %}
						{% endif %}
						{% if forum_settings.PM_SUPPORT %}
							{% if user.is_authenticated %}
								<a href="{% url messages_compose_to post.user.username %}">{% trans "PM" %}</a>&nbsp;&nbsp;</dd>
							{% endif %}
						{% endif %}
				</dl>
			</div>
			<div class="postright">
				<h3>{{ post.topic.name }}</h3>
				<div class="postmsg">
					{{ post.body_html|safe }}
					{% if not user.is_authenticated or user.forum_profile.show_signatures %}
						{% if post.user.forum_profile.signature_html %}
						<div class="postsignature">
							<br /><br/ >
							{{ post.user.forum_profile.signature_html|safe }}
						</div>
						{% endif %}
					{% endif %}
					{% if post.updated %}
						<p class="postedit"><em>{% trans "Edited" %} {{ post.updated_by.username }} ({% forum_time post.updated %})</em></p>
					{% endif %}
					{% with post.attachments.all as attachments %}
						{% if attachments %}
							{% for attach in attachments %}
								<p class="postedit"><em>{% trans "Attachments:" %} <br />{{ attach|attachment_link }}</em></p>
							{% endfor %}
						{% endif %}
					{% endwith %}
				</div>
			</div>
			<div class="clearer"></div>
			<div class="postfootleft">
				{% if post.user|online %}
					<p><strong>{% trans "Online" %}</strong></p>
				{% else %}
					<p>{% trans "Offline" %}</p>
				{% endif %}
			</div>
			<div class="postfootright">
				<ul>
					<li class="postreport"><a href="{% url djangobb:misc %}?action=report&amp;post_id={{ post.id }}">{% trans "Report" %}</a> </li>
					{% if moderator or post|forum_equal_to:last_post %}
						{% if moderator or post.user|forum_equal_to:user %}
							<li class="postdelete">| <a onclick="return confirm('{% trans "Are you sure you want to delete this post?" %}')" href="{% url djangobb:delete_post post.id %}">{% trans "Delete" %}</a> </li>
						{% endif %}
					{% endif %}
					{% if moderator or post|forum_posted_by:user %}
						<li class="postedit">| <a href="{% url djangobb:edit_post post.id %}">{% trans "Edit" %}</a> </li>
					{% endif %}
					<li class="postquote">| <a href="{% url djangobb:add_post topic.id %}?post_id={{ post.id }}">{% trans "Reply" %}</a> </li>
					{% if user.is_authenticated %}
						<li class="postquote">| <a onmouseover="copyQ('{{ post.user.username }}');" href="javascript:pasteQ();">{% trans "Quote" %}</a></li>
					{% endif %}
				</ul>
			</div>
		</div>
	</div>
</div>
{% endfor %}
<div class="postlinksb">
	<div class="inbox">
		<div class="pagelink conl">{% paginate %}</div>
		<p class="postlink conr"><a href="{% url djangobb:add_post topic.id %}">{% trans "Reply" %}</a></p>
				<ul><li><a href="{% url djangobb:index %}">{% trans "Root" %} </a></li><li>&raquo; {% link topic.forum %} </li><li>&raquo; {{ topic }}
				<a href="{% url djangobb:forum_topic_feed topic.id %}"><img src="{{ STATIC_URL }}djangobb_forum/img/feed-icon-small.png"  alt="[RSS Feed]" title="[RSS Feed]" class="breadcrumb_rss" /></a>
				</li></ul>
		{% if user.is_authenticated %}
			{% if subscribed %}
				<a class="subscribelink clearb" href="{% url djangobb:forum_delete_subscription topic.id %}?from_topic">{% trans "Unsubscribe" %}</a>
			{% else %}
				<a class="subscribelink clearb" href="{% url djangobb:forum_add_subscription topic.id %}">{% trans "Subscribe" %}</a>
			{% endif %}
		{% endif %}
		<div class="clearer"></div>
	</div>
</div>
{% if not topic.closed and user.is_authenticated %}
<div class="blockform">
	<h2><span>{% trans "Quick post" %}</span></h2>
	<div class="box">
		<form id="post" action="{% url djangobb:add_post topic.id %}" method="post" enctype="multipart/form-data">
			{% csrf_token %}
			<div class="inform">
				<fieldset>
					<legend>{% trans "Write your message and submit" %}</legend>
					<div class="infldset txtarea">
						{{ form.body }}
					</div>
				</fieldset>
			</div>
			{% if forum_settings.ATTACHMENT_SUPPORT %}
				<div class="inform">
					<fieldset>
						<legend>{% trans "Attachment" %}</legend>
						<div class="infldset">
							<div class="rbox">
								{{ form.attachment }}
							</div>
						</div>
					</fieldset>
				</div>
			{% endif %}
			<p><input type="submit" value="{% trans "Submit" %}" /></p>
		</form>
	</div>
</div>
{% endif %}
{% endblock %}

{% block controls %}
<div class="conl">
	<form id="qjump" method="get" action="forum">
		<div><label>{% trans "Jump to " %}
		<br />
		<select name="id" id="forum_id" onchange="window.location=('{% url djangobb:index %}'+this.options[this.selectedIndex].value)">
			{% for category in categories %}
				<optgroup label="{{ category }}">
					{% for forum in category.forums.all %}
						<option value="{{ forum.id }}">{{ forum }}</option>
					{% endfor %}
				</optgroup>
			{% endfor %}
		</select>
		<input type="button" onclick="window.location=('{% url djangobb:index %}'+getElementById('forum_id').value)" value=" {% trans "Go" %} " accesskey="g" />
		</label></div>
	</form>
	<dl id="modcontrols"><dt><strong>{% trans "Moderator control" %}</strong></dt>
	{% if moderator %}
		<dd><a href="{% url djangobb:delete_posts topic.id %}">{% trans "Delete multiple posts" %}</a></dd>
		<dd><a href="{% url djangobb:move_topic %}?topic_id={{ topic.id }}">{% trans "Move topic" %}</a></dd>
		{% if topic.closed %}
			<dd><a href="{% url djangobb:open_close_topic topic.id 'o' %}">{% trans "Open topic" %}</a></dd>
		{% else %}
			<dd><a href="{% url djangobb:open_close_topic topic.id 'c' %}">{% trans "Close topic" %}</a></dd>
		{% endif %}
		{% if topic.sticky %}
			<dd><a href="{% url djangobb:stick_unstick_topic topic.id 'u' %}">{% trans "Unstick topic" %}</a></dd></dl>
		{% else %}
			<dd><a href="{% url djangobb:stick_unstick_topic topic.id 's' %}">{% trans "Stick topic" %}</a></dd></dl>
		{% endif %}
	{% endif %}
    </dl>
</div>
{% endblock %}

{% block lofi %}
{% if forum_settings.LOFI_SUPPORT %}
    <p class="lofi">
        <a href="{{ topic.get_absolute_url }}lofi/">Lo-Fi Version</a>
    </p>
{% endif %}
{% endblock %}
